package org.example.response;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ApiResponse<T> {
    private int code;
    private String msg;
    private T data;

    public ApiResponse(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static <T> ApiResponse<T> success(T data) {
        return new ApiResponse<T>(200, "success", data);
    }

    public static <T> ApiResponse<T> error(String msg) {
        return new ApiResponse<T>(500, msg);
    }

    public static <T> ApiResponse<T> notFound(int code, String msg) {
        return new ApiResponse<T>(404, msg);
    }
}
